//
//  LDBaseRefreshView.swift
//  DingDongZP
//
//  Created by 三秒文化 on 16/5/30.
//  Copyright © 2016年 iyhjiang.com. All rights reserved.
//

import UIKit
import MJRefresh

class LDBaseRefreshView: NSObject{


    private
    var imagesArr = [UIImage]()
    
    internal func header(closure:(()->Void)) ->MJRefreshHeader {
        
        let header = MJRefreshGifHeader.init { //[weak self] in
            
            closure()
        }
        header.setImages(imagesArr, forState: MJRefreshState.Idle)
        header.setImages(imagesArr, forState: MJRefreshState.Pulling)
//        header.automaticallyChangeAlpha = true
        header.lastUpdatedTimeLabel.hidden = true
        header.stateLabel.hidden = true
        
        return header

    }
    
    internal func footer(closure:(()->Void)) ->MJRefreshBackStateFooter {
        
        
        let footer = MJRefreshBackNormalFooter.init(refreshingBlock: { //[weak self] in

            closure()
            })
        
        footer.automaticallyChangeAlpha = true
        return footer
    }

    
    //入口
    class var sharedInstance:LDBaseRefreshView {
        struct Staics {
            static let instance = LDBaseRefreshView()
        }
        return Staics.instance
    }
    
    private
    override init() {
        super.init()
        
        for i in 1...10 {
            let imgname = String(format: "downwards－%d",i)
            let img = UIImage(named: imgname) ?? UIImage()
            imagesArr.append(img)
        }
        
    }
}
